import React, { Component } from 'react'
import axios from 'axios';
export default class Proxy extends Component {
  render() {
    return (
      <div>
          <button onClick={this.getStudents}>获取学生</button>
          <button onClick={this.getCars}>获取汽车</button>
          <button onClick={this.getStudents2}>获取咱们班同学</button>
      </div>
    )
  }

  getStudents = async () => {
      //发送 AJAX 请求                     /students
        let result = await axios.get('/api1/students'); // students  => 5000
        console.log(result);
  }

  getCars = async () => {
      //发送请求
      let result = await axios.get('/api2/cars');  // /cars =>  5001 
      console.log(result);
  }

  getStudents2 = async () => {
    let result = await axios.get('/api2/students');
    console.log(result);


  }
}
